package com.bootcamp.s3_1013.database.utils;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * @program: myClassCode
 * @description: c3p0 utils class
 * @author: Keyu Li
 * @create: 2021-10-19 20:20
 **/

public class C3P0Utils {

    static DataSource dataSource = new ComboPooledDataSource();

    public static Connection getConnection(){
        try {
            return dataSource.getConnection();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
            return null;
        }
    }

    public static DataSource getDataSource(){
        return dataSource;
    }

}
